﻿CREATE PROCEDURE [dbo].[ReportCustomerSummary]
@CustID INT
AS
BEGIN
	SELECT Customer.CustomerName, Projects.Name, Users.UserName, EntryLog.EntryDate, EntryLog.Description, EntryLog.Duration
	FROM  EntryLog INNER JOIN
               Users ON EntryLog.UserID = Users.UserID INNER JOIN
               Projects ON EntryLog.ProjectID = Projects.ProjectID LEFT OUTER JOIN
               CustomerProject ON CustomerProject.ProjectID = Projects.ProjectID LEFT OUTER JOIN
               Customer ON Customer.CustomerID = CustomerProject.CustomerID
	WHERE (EntryLog.EntryDate > DATEADD(Day, - 7, GETDATE())) AND (Customer.CustomerID = @CustID)
	ORDER BY Customer.CustomerName, Projects.Name, Users.UserName, EntryLog.EntryDate
END

